<template>
    <div class = 'right-container'>
        <!-- 权限面包屑导航-->
        <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>权限管理</el-breadcrumb-item>
        <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>
        <!-- 权限列表 -->
        <el-card >
            <el-table :data="rightList" style="width:100%" height="100vh" :default-sort = "{prop: 'level'}" border stripe>
                <el-table-column type='index'></el-table-column>
                <el-table-column prop="authName" label="权限名称"></el-table-column>
                <el-table-column prop="path" label="路径"></el-table-column>
                <el-table-column prop="level" label="权限等级"  >
                    <!-- 权限等级作用域插槽 -->
                    <template slot-scope="scope">
                        <el-tag type="primary" v-if="scope.row.level == 0">一级</el-tag>
                        <el-tag type="success" v-else-if="scope.row.level == 1">二级</el-tag>
                        <el-tag type="warning" v-else>三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script>
export default {
    data(){
        return{
            rightList:[]
        }
    },
    // 权限组件创建
    created(){
        // 获取所有权限数据
        this.getRightList();

    },
    methods:{
        // 获取权限数据
        async getRightList(){
            // const {data : res} = await this.$http.get('/rights/list');
            const {data : res} = await this.$http.get('/rights/list');

            // if(res.meta.status !== 200 ) return this.$Message.error('权限数据获取失败！')
            this.$Message.success('权限数据获取成功！')
            console.log(res.data);
            this.rightList = res.data
        }
    }

}
</script>

<style lang="less" scoped>

.el-card{
    box-shadow:0 0 3px #ddd;
    margin-top:20px;
    width: 98%;
}
</style>